//
//  CommentTableViewCell.m
//  KeleAppProject
//
//  Created by 周岑 on 2018/1/22.
//  Copyright © 2018年 Cen Zhou. All rights reserved.
//

#import "CommentTableViewCell.h"
#import "LogoNumberView.h"


@interface CommentTableViewCell()

@property (nonatomic, strong) YYTextLayout *layout;
@end

@implementation CommentTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self loadSubviewsOnComment];
    }
    return self;
}

- (void)loadSubviewsOnComment{
    UIImageView *profileImageView = [[UIImageView alloc]init];
    profileImageView.image = [UIImage imageNamed:@"info_touxiang"];
    profileImageView.layer.masksToBounds = YES;
    profileImageView.layer.cornerRadius = 14*WIDTH;
    [self.contentView addSubview:profileImageView];
    [profileImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(28*WIDTH);
        make.top.equalTo(self.contentView).offset(15*HEIGHT);
        make.left.equalTo(self.contentView).offset(15*WIDTH);
    }];
    
    UILabel *nameLb = [[UILabel alloc]init];
    nameLb.text = @"哈哈哈";
    nameLb.textColor = KLColor_B11;
    nameLb.font = [UIFont fontWithName:@"PingFangSC-Medium" size:13*WIDTH];;
    [self.contentView addSubview:nameLb];
    [nameLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(15*HEIGHT);
        make.left.equalTo(profileImageView.mas_right).offset(8*WIDTH);
    }];
    
    LogoNumberView *praseNum = [[LogoNumberView alloc]init];
    [self.contentView addSubview:praseNum];
    [praseNum mas_updateConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(nameLb);
        make.right.equalTo(self.contentView).offset(-15*WIDTH);
        make.width.mas_equalTo(50*WIDTH);
        make.height.mas_equalTo(20*HEIGHT);
    }];
    
    [praseNum setValuesWithDataDic:@{@"imageStr":@"home_icon_dianzan",@"title":@"756"}];
    
    YYLabel *textLabel = [YYLabel new];
    textLabel.text = @"视频标题内容视频标题内容视频标题内容视频标题内容视频标题内容";
    NSMutableAttributedString *text = [[NSMutableAttributedString alloc]initWithString:textLabel.text];
    text.yy_color = KLColor_B6;
    text.yy_font = [UIFont fontWithName:@"PingFangSC-Regular" size:14*WIDTH];
    CGSize size = CGSizeMake(KLScreenW - 66*WIDTH, CGFLOAT_MAX);
    YYTextLayout *layout = [YYTextLayout layoutWithContainerSize:size text:text];
    textLabel.textLayout = layout;
    self.layout = layout;
    [self.contentView addSubview:textLabel];
    [textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(nameLb.mas_bottom).offset(4*HEIGHT);
        make.left.equalTo(nameLb);
        make.right.equalTo(self.contentView).offset(-15*WIDTH);
        make.height.mas_equalTo(layout.textBoundingSize.height);
    }];
    
    UILabel *timeLb = [[UILabel alloc]init];
    timeLb.text = @"15分钟前";
    timeLb.textColor = KLColor_B7;
    timeLb.font = [UIFont fontWithName:@"PingFangSC-Regular" size:12*WIDTH];
    [self.contentView addSubview:timeLb];
    [timeLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(textLabel.mas_bottom).offset(4*HEIGHT);
        make.left.equalTo(nameLb);
    }];
    
    
    UIButton *replyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [replyBtn setTitle:@"回复Ta" forState:UIControlStateNormal];
    [replyBtn setTitleColor:KLColor_B7 forState:UIControlStateNormal];
    replyBtn.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:12*WIDTH];
    [self.contentView addSubview:replyBtn];
    [replyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(timeLb);
        make.left.equalTo(timeLb.mas_right).offset(15*WIDTH);
        make.width.mas_equalTo(40*WIDTH);
        make.height.mas_equalTo(17*HEIGHT);
    }];
    
    UIView *replayView = [[UIView alloc]init];
    replayView.backgroundColor = KLColor_C1;
    [self.contentView addSubview:replayView];
    [replayView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(timeLb.mas_bottom).offset(10*HEIGHT);
        make.left.equalTo(timeLb);
        make.width.mas_equalTo(309*WIDTH);
        make.height.mas_equalTo(109*HEIGHT);
    }];
    
    UILabel *replyName = [[UILabel alloc]init];
    replyName.text = @"为下呗: 放得开；阿凡达客户开发健康大回复即可";
    replyName.numberOfLines = 0;
    replyName.textColor = KLColor_B2;
    [replyName changeTextColorWithRange:NSMakeRange(0, 3) color:KLColor_B11];
    
    replyName.font = [UIFont fontWithName:@"PingFangSC-Regular" size:13*WIDTH];
    [replayView addSubview:replyName];
    [replyName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(replayView).offset(10*HEIGHT);
        make.left.equalTo(replayView).offset(8*WIDTH);
    }];
    
    
    
}


@end
